{include file="public/header" /}

<body>
<div class="layui-card">
    <div class="layui-card-body">
        <div class="layui-tab-content">
            <form id="faqFormData" class="layui-form layui-form-pane" autocomplete="off">
                <div class="layui-form-item">
                    <label class="layui-form-label layui-required">问题标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" id="title" class="layui-input" placeholder="请输入">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-required">回答</label>
                    <div class="layui-input-block">
                        <textarea name="answer" placeholder="请输入" class="layui-textarea"></textarea>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">排序</label>
                    <div class="layui-input-block">
                        <input type="text" name="sort" id="sort" value="255" class="layui-input" placeholder="请输入排序，数字越小，排序越靠前">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="checkbox" name="status" id="status" checked lay-text="显示|隐藏" lay-skin="switch">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" onclick="sendFormData()" class="layui-btn layui-btn-normal">提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>

<script>
    layui.use('form',function () {
        var $ = layui.jquery,
            form = layui.form;
    })

    function sendFormData() {
        var faqAddLoad = layer.load(1,{shade:[0.5,'#FFF'],time:0})
        let data = $("#faqFormData").serialize()
        ajaxRequest("{:url('faq/add')}",data,function (res) {
            if (res.code == 'suc') {
                sucMsg(res.msg,function () {
                    //刷新父级页面
                    parent.layui.table.reload('faqList')
                    //关闭遮罩层
                    layer.close(faqAddLoad)
                    //关闭当前弹出层
                    xadmin.close()
                })
            } else {
                errMsg(res.msg,function () {
                    //关闭遮罩层
                    layer.close(faqAddLoad)
                })
            }
        })
    }
</script>